package com.gexiaobao.pigeon.ui.adapter

import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.base.DataBindBaseViewHolder
import com.gexiaobao.pigeon.app.model.bean.AllVisitInfoResponse
import com.gexiaobao.pigeon.databinding.ItemAllVisitInfoBinding

/**
 * @Author      : hxw
 * @Date        : 2024/6/8 11:15
 * @Describe    :
 */
class AllVisitInfoAdapter(data: ArrayList<AllVisitInfoResponse.ListBean>) :
    BaseQuickAdapter<AllVisitInfoResponse.ListBean, DataBindBaseViewHolder>(R.layout.item_all_visit_info, data) {

    override fun convert(holder: DataBindBaseViewHolder, item: AllVisitInfoResponse.ListBean) {
        val binding = DataBindBaseViewHolder.getBinding(holder) as ItemAllVisitInfoBinding
        binding.data = item
        binding.executePendingBindings()//防止列表抖动

        if (holder.layoutPosition % 2 == 0) {
            holder.setBackgroundColor(R.id.llItem, ContextCompat.getColor(context, R.color.comm_bg))
        } else {
            holder.setBackgroundColor(R.id.llItem, ContextCompat.getColor(context, R.color.white))
        }

        holder.setGone(R.id.tvAllVisitState, !item.isPayState)

        val visitType = when (item.visitType) {
            1 -> context.getString(R.string.On_site_visit)//现场探视"
            2 -> context.getString(R.string.Video_visitation)//"视频探视"
            3 -> context.getString(R.string.No_visitation)//"不探视"
            else -> "--"
        }
        holder.setText(R.id.tvItemAllVisitType, visitType)
        val state = when (item.state) {
            1 -> "待审核"//"审核中"
            2 -> "已缴费"//"审核通过"
//            3 -> context.getString(R.string.Review_and_reject)//"审核驳回"
            else -> "--"
        }
        holder.setText(R.id.tvAllVisitState, state)
        if (item.state == 1) {
            holder.setTextColor(R.id.tvAllVisitState, ContextCompat.getColor(context, R.color.color_f65a5a))
        } else {
            holder.setTextColor(R.id.tvAllVisitState, ContextCompat.getColor(context, R.color.comm_text_gray_dark))
        }
    }

}